package com.daocao.hua.interfaces;

import android.app.Activity;
import android.webkit.JavascriptInterface;

import com.daocao.hua.util.RBLog;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class JSInterface {
    private String TAG = "JSInterface";
    private Activity activity = null;
    private RequestCallBack callBack;

    public JSInterface(Activity activity, RequestCallBack requestCallBack) {
        this.activity = activity;
        this.callBack = requestCallBack;
    }

    @JavascriptInterface
    public void payCallBack(String paramString) {

        try {
            String str = URLDecoder.decode(paramString, "UTF-8");
            paramString = str;
            RBLog.e("payCallBack:  ", paramString);
            if (paramString.equals("true")) {
                callBack.success();
            } else
                callBack.fail();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

    }

    /**
     * 数据回调接口
     */
    public interface RequestCallBack {
        void fail();

        void success();
    }
}